// This example shows how to write a value into a single node that is of type ByteString. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . using System; using OpcLabs.EasyOpc.UA; using OpcLabs.EasyOpc.UA.OperationModel; namespace UADocExamples._EasyUAClient { partial class WriteValue { public static void ByteString() { UAEndpointDescriptor endpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"; // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) // or "https://opcua.demo-this.com:51212/UA/SampleServer/" // Instantiate the client object. var client = new EasyUAClient(); Console.WriteLine("Modifying value of a node..."); try { client.WriteValue(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10230", new byte[] {11, 22, 33, 44, 55}); } catch (UAException uaException) { Console.WriteLine($"*** Failure: {uaException.GetBaseException().Message}"); return; } Console.WriteLine("Finished."); } } }
# This example shows how to write a value into a single node that is of type ByteString. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . #requires -Version 5.1 using namespace OpcLabs.EasyOpc.UA using namespace OpcLabs.EasyOpc.UA.AddressSpace using namespace OpcLabs.EasyOpc.UA.OperationModel # The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows . Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUA.dll" Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUAComponents.dll" [UAEndpointDescriptor]$endpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" # or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) # or "https://opcua.demo-this.com:51212/UA/SampleServer/" # Instantiate the client object. $client = New-Object EasyUAClient Write-Host "Modifying value of a node..." try { $client.WriteValue($endpointDescriptor, [UANodeId]"nsu=http://test.org/UA/Data/ ;i=10230", @(11, 22, 33, 44, 55)) } catch [UAException] { Write-Host "*** Failure: $($PSItem.Exception.GetBaseException().Message)" return } Write-Host "Finished."
# This example shows how to write a value into a single node that is of type ByteString. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python . # The QuickOPC package is needed. Install it using "pip install opclabs_quickopc". import opclabs_quickopc # Import .NET namespaces. from OpcLabs.EasyOpc.UA import * from OpcLabs.EasyOpc.UA.OperationModel import * endpointDescriptor = UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:51210/UA/SampleServer') # or 'http://opcua.demo-this.com:51211/UA/SampleServer' (currently not supported) # or 'https://opcua.demo-this.com:51212/UA/SampleServer/' # Instantiate the client object. client = EasyUAClient() print('Modifying value of a node...') try: IEasyUAClientExtension.WriteValue(client, endpointDescriptor, UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10230'), [11, 22, 33, 44, 55]) except UAException as uaException: print('*** Failure: ' + uaException.GetBaseException().Message) exit() print('Finished.')
' This example shows how to write a value into a single node that is of type ByteString. ' ' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . Imports OpcLabs.EasyOpc.UA Imports OpcLabs.EasyOpc.UA.OperationModel Namespace _EasyUAClient Partial Friend Class WriteValue Public Shared Sub ByteString() ' Define which server we will work with. Dim endpointDescriptor As UAEndpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" ' or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) ' or "https://opcua.demo-this.com:51212/UA/SampleServer/" ' Instantiate the client object Dim client = New EasyUAClient() ' Modify value of a node Try client.WriteValue(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10230", New Byte() {11, 22, 33, 44, 55}) Catch uaException As UAException Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message) Exit Sub End Try End Sub End Class End Namespace
// This example shows how to write a value into a single node that is of type ByteString. // // Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . #include "stdafx.h" // Includes "QuickOpc.h", and other commonly used files #include <atlcom.h> #include <atlsafe.h> #include "WriteValue.h" namespace _EasyUAClient { void WriteValue::ByteString() { // Initialize the COM library CoInitializeEx(NULL, COINIT_MULTITHREADED); { // Instantiate the client object _EasyUAClientPtr ClientPtr(__uuidof(EasyUAClient)); // Prepare the value to be written CComSafeArray<BYTE> array(5); array.SetAt(0, 11); array.SetAt(1, 22); array.SetAt(2, 33); array.SetAt(3, 44); array.SetAt(4, 55); const CComVariant value(array); // Perform the operation ClientPtr->WriteValue( //L"http://opcua.demo-this.com:51211/UA/SampleServer", L"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer", L"nsu=http://test.org/UA/Data/ ;i=10230", value); } // Release all interface pointers BEFORE calling CoUninitialize() CoUninitialize(); } }
// This example shows how to write a value into a single node that is of type ByteString. // // Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . class procedure WriteValue.ByteString; var Client: OpcLabs_EasyOpcUA_TLB._EasyUAClient; Values: OleVariant; begin Values := VarArrayCreate([0, 4], varByte); Values[0] := 11; Values[1] := 22; Values[2] := 33; Values[3] := 44; Values[4] := 55; // Instantiate the client object Client := CoEasyUAClient.Create; // Modify value of a node try Client.WriteValue( //'http://opcua.demo-this.com:51211/UA/SampleServer', //'https://opcua.demo-this.com:51212/UA/SampleServer/', 'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer', 'nsu=http://test.org/UA/Data/ ;i=10230', Values); except on E: EOleException do begin WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message])); Exit; end; end; VarClear(Values); end;
// This example shows how to write a value into a single node that is of type ByteString. // // Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . $Values[0] = 11; $Values[1] = 22; $Values[2] = 33; $Values[3] = 44; $Values[4] = 55; // Instantiate the client object $Client = new COM("OpcLabs.EasyOpc.UA.EasyUAClient"); // Modify value of a node try { $Client->WriteValue( //"http://opcua.demo-this.com:51211/UA/SampleServer", "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer", "nsu=http://test.org/UA/Data/ ;i=10230", $Values); } catch (com_exception $e) { printf("*** Failure: %s\n", $e->getMessage()); }
REM This example shows how to write a value into a single node that is of type ByteString. REM REM Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . Public Sub WriteValue_ByteString_Command_Click() OutputText = "" Dim Values(4) As Byte Values(0) = 11 Values(1) = 22 Values(2) = 33 Values(3) = 44 Values(4) = 55 ' Instantiate the client object Dim Client As New EasyUAClient ' Perform the operation On Error Resume Next Call Client.WriteValue("opc.tcp://opcua.demo-this.com:51210/UA/SampleServer", "nsu=http://test.org/UA/Data/ ;i=10230", Values) If Err.Number <> 0 Then OutputText = OutputText & "*** Failure: " & Err.Source & ": " & Err.Description & vbCrLf Exit Sub End If On Error GoTo 0 End Sub
Copyright © 2004-2024 CODE Consulting and Development, s.r.o., Plzen. All rights reserved. Web page: www.opclabs.com
Send Documentation Feedback. Resources: Knowledge Base, Product Downloads. Technical support: Online Forums, FAQ.Missing some example? Ask us for it on our Online Forums! You do not have to own a commercial license in order to use Online Forums, and we reply to every post.